package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {
    // mybatis-plus只提供基本的增删改查 其他的都不提供  其他的需要自定义方法
//    今日的新增 和 今日的登陆
    @Select("select count(distinct user_id) from tb_log where type=#{type} and log_time=#{logTime}")
    public Integer findByLoginOrRegister(@Param("type") String type, @Param("logTime") String logTime);

    //活跃用户
    @Select("select count(distinct user_id)from tb_log where log_time=#{logTime}")
    public Integer findActivebyLogTime(String logTime);

    //次日留存用户
    @Select("select count(distinct user_id) from tb_log where log_time=#{today} and user_id in" +
            "(select distinct user_id from tb_log where type = '0102' and log_time =#{yesterday} )")
    public Integer findRetention(@Param("yesterday")String yesterday, @Param("today")String today);
}